﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using NUnit.Framework;
using System.IO;

namespace AxialWeb.Tests
{
	public class TestBase
	{
		private Process p;

		[TestFixtureSetUp]
		public void SetUp()
		{
			// create a new process to start the ASP.Net Development Server
			p = new Process();
			string path = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName + @"\";
			p.StartInfo.FileName = "WebDev.WebServer.EXE";
			p.StartInfo.WorkingDirectory = @"C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\";
			if (!File.Exists(Path.Combine(p.StartInfo.WorkingDirectory, p.StartInfo.FileName)))
				p.StartInfo.WorkingDirectory = @"C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\9.0";
			p.StartInfo.Arguments = String.Format("/port:2877 /path:\"{0}AxialWeb\"", path);
			p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
			p.Start();
		}

		[TestFixtureTearDown]
		public void Dispose()
		{
			// kill the ASP.NET Development Server process
			p.Kill();
		}

		protected WatiN.Core.IE CreateIE(string page)
		{
			return new WatiN.Core.IE("http://localhost:2877/" + page);
		}
	}
}
